<?php
namespace app\admin\controller;
use think\Controller;

class Base extends Controller{

     protected $jcuserId='';
    
     public function _initialize (){
            $jcuser = session("jcuserId");
            if(!$jcuser){
                session(null);
                $this->redirect('login/index');
            }
            $this->jcuserId=$jcuser;
            $this->assign("apihost",config("httpurl")."/admin/Api/");
        }


     public function __construct(){
          parent::__construct(); //调用父类的构造方法
      }


      public  function param_error()
        {
            $_arr['flag'] = -1;
            $_arr['msg'] = '参数错误';
            $_arr['data'] = '';
            return json($_arr);
        }

        protected function returnError($errorMsg='',$data='')
        {
            $_arr['flag'] = -1;
            $_arr['msg'] = $errorMsg;
            $_arr['data'] = $data;
            return json($_arr);
        }

        protected function returnAlert($alertMsg='',$data='')
        {
            $_arr['flag'] = 1;
            $_arr['msg'] = $alertMsg;
            $_arr['data'] = $data;
            return json($_arr);
        }

        protected function returnOk($data='',$msg='')
        {
            $_arr['flag'] = 0;
            $_arr['msg'] = $msg;
            $_arr['data'] = $data;
            return json($_arr);
        }

        public function _empty()
        {
            $this->redirect("Error/index");
        }


}